/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2025-03-02
 * Time: 11:06
 */
public class Main {
    //移动0（by myself）
    public void moveZeroes(int[] nums) {
        int dest = -1;
        int cur = 0;
        int l = nums.length;
        while(l != 0 && cur < nums.length){
            if(nums[cur] == 0){
                cur++;
            }else{
                int tmp = nums[cur];
                nums[cur] = nums[dest+1];
                nums[dest+1] = tmp;
                cur++;
                dest++;
            }
        }
    }
    //teacher
    public void moveZeroes1(int[] nums){
        for (int cur = 0,dest = -1; cur < nums.length; cur++) {
            if (nums[cur] != 0){
                dest++;
                int tmp = nums[cur];
                nums[cur] = nums[dest];
                nums[dest] = tmp;
            }
        }
    }
}
